package demo.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.mvc.action.Action;
import com.mvc.annocation.ActionMapping;
import com.mvc.annocation.Controller;
import com.mvc.form.ActionForm;

import demo.form.LoginForm;

@Controller(action="/loginAction",form="demo.form.LoginForm")
public class LoginAction extends Action {

	@ActionMapping(path="login",successUrl="/page/loginSuccess.jsp",failUrl="/index.jsp")
	public String login(HttpServletRequest req,
			HttpServletResponse resp, ActionForm form) {
		resp.setCharacterEncoding("UTF-8");
		LoginForm loginForm = (LoginForm) form;
		if("tty".equals(loginForm.getUserName())){
			req.setAttribute("msg", "成功！");
			return "success";
		}else{
			req.setAttribute("msg", "用户名不存在");
			return "fail";
		}
	}

}
